import axios from 'axios';

axios.defaults.baseURL = 'http://127.0.0.1:9115'

// 封装请求
function http(params) {
	return axios({...params}).then(res => res.data).catch(err => err);
}

// 封装网络请求可以单次或者多次请求
async function network(params) {
	// 判断是否是多次请求
	if (params instanceof Array) {
		// 定义数组保存返回值
		let results = [];
		for (let index in params) {
			let result = await http(params[index]);
			results.push(result);
		}
		return results
	} else {
		return await http(params);
	}
}

export default network;